package com.baosight.risk.web.fltd;

import com.baosight.risk.api.fltd.FlaaNodeService;
import com.baosight.risk.api.fltd.FltdProcessService;
import com.baosight.risk.base.controller.BaseController;
import com.baosight.risk.common.result.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;

/**
 * 作者： lishaoqing
 * 时间： 2019年08月26日
 * 描述： FlaaNodeController
 * 版本: v1.0
 */
@Api(value = "流程节点扩展参数", description = "流程节点扩展参数", produces = MediaType.APPLICATION_JSON)
@Slf4j
@RestController
@RequestMapping("/fltd/nodeExt")
public class FlaaNodeController extends BaseController {

    @Autowired
    private FltdProcessService fltdProcessService;

    @Autowired
    private FlaaNodeService flaaNodeService;

    @ApiOperation("查询节点扩展参数")
    @GetMapping("ext")
    public AjaxResult selectNodeExt(String flowNo, String nodeCode) {
        Map<String, Object> extMap = new HashMap<>();
        if (fltdProcessService.convertExt(flowNo, nodeCode, extMap)) {
            return AjaxResult.success("查询成功", extMap);
        } else {
            return AjaxResult.error();
        }
    }

    @ApiOperation("查询节点的催办配置")
    @GetMapping("urgent")
    public AjaxResult selectNodeUrgent(String flowNo, String nodeCode) {
        return success("查询成功", flaaNodeService.selectUrgent(flowNo, nodeCode));
    }

    @ApiOperation("批量查询节点的催办配置")
    @GetMapping("batchUrgent")
    public AjaxResult batchSelectNodeUrgent(String flowNo, String nodeCode) {
        return success("查询成功", flaaNodeService.batchSelectUrgent(flowNo, nodeCode));
    }


    /**
     * 风险结题查询催办配置(不规范写死,待修改,这里查询的是风险自评的催办配置)
     * @param
     * @return
     * @throws Exception
     */
    @ApiOperation("查询风险结题节点的催办配置")
    @GetMapping("finishUrgent")
    public AjaxResult finishUrgent()  throws Exception {
        String flowNo="fengxianziping";
        String nodeCode="A01";
        return success("查询成功", flaaNodeService.selectUrgent(flowNo, nodeCode));
    }

}
